package com.ahchentong.easyexcel.controller;

import com.ahchentong.easyexcel.bean.ExpertBaseEntity;
import com.ahchentong.easyexcel.listener.ExpertBaseListener;
import com.alibaba.excel.EasyExcel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController()
public class ApiController {
    @GetMapping("/test")
    public String test(){
        return "test20201010";
    }

    @PostMapping("upload")
    @ResponseBody
    public String upload(MultipartFile file) throws IOException {
        EasyExcel.read(file.getInputStream(), ExpertBaseEntity.class, new ExpertBaseListener()).sheet().headRowNumber(5).doRead();
        return "success";
    }
}
